﻿using B.S.GridManage.Domain.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B.S.GridManage.Infrastructure.Interface
{
    /// <summary>
    /// 仓储接口
    /// </summary>
    public interface IBaseRepository<T> where T : BaseEntity
    {
        //定义四个接口方法 增删改查

        /// <summary>
        /// 新增实体
        /// </summary>
        /// <param name="t">要新增的实体对象</param>
        /// <returns>受影响的行数</returns>
        Task<int> CreateAsync(T t);
        /// <summary>
        /// 更新实体
        /// </summary>
        /// <param name="t">要修改的实体对象</param>
        /// <returns>受影响的行数</returns>
        Task<int> UpdateAsync(T t);

        /// <summary>
        /// 获取指定id的实体对象
        /// </summary>
        /// <param name="id">id</param>
        /// <returns>实体对象</returns>
        Task<T> GetModel(long id);

        /// <summary>
        /// 获取所有数据的表达式
        /// </summary>
        /// <returns>表达式</returns>
        IQueryable<T> GetAll();

        Task<int> AddRangeAsync(List<T> entities);
    }
}
